﻿var mt = mt || {};
mt.vm = mt.vm || {};
mt.vm.failTime = 0;
mt.vm.pingFunc = function () {
    abp.ajax({
        url: '/Other/Ping?p=' + (new Date().getTime())
    }).then(function (result) {
        if (result == "1") {
            mt.vm.failTime = 0;
            setTimeout(mt.vm.pingFunc, 60000);        } else {
            //用户不在线or服务器回收等
            window.location.href = "/Account/Login";
        }
    }).fail(function () {
        //服务器无响应等
        mt.vm.failTime++;
        if (mt.vm.failTime > 2) {
            window.location.href = "/Account/Login";
        } else {
            setTimeout(mt.vm.pingFunc, 60000);
        }
    });
};
setTimeout(mt.vm.pingFunc, 60000);